package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"practice-one/api/internal/config"
	"practice-one/api/internal/middleware"
	"practice-one/userrpc/userrpcclient"
)

type ServiceContext struct {
	Config config.Config

	UserRpc userrpcclient.Userrpc

	UserAgentMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,

		UserRpc: userrpcclient.NewUserrpc(zrpc.MustNewClient(c.UserRpc)),

		UserAgentMiddleware: middleware.NewUserAgentMiddleware().Handle,
	}
}
